<?php

namespace App\Http\Controllers\Vhome;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    //访问网站前台首页
	public function index(){
		//显示网站前台首页
		return view('Vhome/index');
	}
	public function insert(Request $request){
		//验证:两次密码是否一致(后台必须验证)
		$pwd = $request->input('upwd');
		$repwd = $request->input('repwd');
		$utel = $request->input('utel');
		$uemail = $request->input('uemail');
		
		if($pwd == $repwd ){
			echo '错误';
		}
		//获取插入的信息
		$user = $request->only(['uname','upwd','uemail']);
		//密码加密操作
		$user['upwd']=md5($user['upwd']);
		
		//将用户数据插入数据库
		$result = DB::table('user')->insert($user);
		
		//判断用户是否插入成功
		if($result){
			return success('/admin/user/index','插入用户成功',1);
		}else{
			return error('/admin/user/add','插入用户失败',3);
		}
	}
}
